## Explanation of Virtual Channel Structure "SoundChannel"

The element vchn[x] for structure SoundArea is the array for SoundChannel. It has all 12 channels. By setting an appropriate value for vchn[x] a direct sound is produced, but if it exceeds the maximum setting in SoundDriverMode() for simultaneously-produced sounds with these channels are ignored.
The elements for the structure SoundChannel are as follows.
u8 sf; // Status
When starting sound production set 0x80, when doing a key off (start release) OR 0x40, and when stopping the sounds for an instant, set 0x00. If this is 0x00, that channel is stopped.
u8 ty; // Type
During a normal sound this is 0x00. If the musical interval is not calculated and sound is produced at high speed this is set to 0x08.
u8 rv; // Right Volume
u8 lv; // Left Volume
The volume of sounds is set in the range of 0-255.
u8 at; // Attack
The attack time is (255/(x)) * 1/60 second. Set in the range from 0-255.
u8 de; // Decay
The decay is (current volume) * ((x)/256) every 1/60 second. If it is less than or equal to the sustain volume, it transfers to sustain status. Set in the range from 0-255.
u8 su; // Sustain
The sustain volume is set in the range of 0-255.
u8 re; // Release
The release is (current volume) * ((x)/256) every 1/60 second. If it is less than or equal to the pseudo-echo volume, it transfers to psuedo-echo status. Set in the range from 0-255.
u8 r1[4]; // Pseudo-Echo Volume ([4] is not number of elements, it is element #)
u8 r1[5]; // Pseudo-Echo Length ([5] is not number of elements, it is element #)
Pseudo-echo is a sound of fixed volume that is leftover for a fixed time after a release ends. Set the volume between 0-255 and the length between 0-127. The amount of time the sound remains is length multiplied by 1/60 second. Additionally, if you are going to use psuedo-echo (volume!=0), the length is counted down so you need to set it again for every sound.
u32 fr; // Frequency Calculation Value
The requested value is set with the previously described function MidiKey2Freq().
WaveData *wp; // Waveform Pointer
This sets the pointer to the waveform data structure described later.

The settings for the structure SoundChannel are done using the following process.
(1) Set 0x00 for sf(Status).
(2) Set ty(Type), rv(Right Volume), lv(Left Volume), at(Attack), de(Decay), su(Sustain),
re(Release), r1[4](Pseudo-Echo Volume), r1[5](Pseudo-Echo Length),
fr(Frequency Calculation Value), and wp(Waveform Pointer).
(3) Set 0x80 for sf(Status) and start sounds.
(4) To change volume while producing sounds, adjust rv(Right Volume) and lv(Left Volume).
(5) To change the interval while producing sounds, adjust fr(Frequency Calculation Value).
(6) If you OR 0x40 for sf(Status), a key off(release start) occurs.
If nothing is done sf soon becomes 0x00 and the sound stops.
(7)To stop the sound instantly, set 0x00 for sf(Status).
If you are not going to use any sounds functions besides those described here, it is fine for the user to use the elements r1[6] - r1[15] and r3[1] - r3[5] for SoundChannel.

[ | Back | Programmer's Manual Table of Contents | Using the Sound Driver Table of Contents | Next | ]